function main(){
    const self = this;
    const btnEle = self.$$("custom_button_4yy3xa");

    let btnEleTitle = btnEle.data.props.operateItem.title;

    let urlBase = api.CONST["bd_var:07bb31e3-e15c-4b1b-ac48-400bc5a1ba8d"];
    const applicationId = self.state.applicationId;
    const tokenKey = `${applicationId}:access_token`;
    const casKey = `${applicationId}:cas_access_token`;
    const token = getParameter('token') || localStorage.getItem(casKey) || localStorage.getItem(tokenKey) || "";
    let caseRegister = '';
    console.log('caseRegister')
    let caseSourceId = this.state.record.id.value

    getRecId(caseSourceId).then(res => {
        let caseSourceId = res.result;
        console.log(recId)
        if(btnEleTitle === "查看案件详情"){
            caseRegister = urlBase + "?egova_token=" + token + "#/case-detail?recId=" + recId
        }else {
            caseRegister = urlBase + "?egova_token=" + token + "#/case-register?sourceId=" + caseSourceId
        }

        window.open(caseRegister, "_self");
    });



    window.open(caseRegister, "_self");
}


function getRecId(caseId) {
    return new Promise((resolve, reject) => {
        api.EXEC_FORMULA("ENTITY_SELECT_ONE('ds_tbl:t_c5e7e0dce464414c8d2f8869af0c3564',rec_id,QUERY_EQ(related_event_id," + caseId + "))").then(res => {
            debugger;
            resolve(res)
        })
    });

}


/**
 * 截取参数
 */
function getParameter(key) {
    const reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
    const match = window.location.href.match(reg);

    if (match) {
        return unescape(match[2]);
    }
    return null;
}
